<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%-- 引入页面头 --%>
<%@ include file="/pageHead.jsp"%>
<form name="form1" id="form1"
	action="<%-- ${systemctx}/sample/saveSample.web --%>" method="post">
	<div class="pageMain">
		<div class="pageTitle"><%=MessageResourcesUtils.getMessage(request, "systemmanage.servicemanagement.title") %>
		<span></span><%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.title") %>
		<span></span><%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.list") %>
		</div>
		<div class="pageBody">
			<div class="form-group">
				<ul>
					<li>
						<i></i>
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.storename") %></label>
						<span><input type="text" id="name" name="name" value="" /></span>
					</li>
					<li>
						<i></i>
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.services.servicesList.servicename") %></label>
						<span><input type="text" id="servicename" name="servicename" value="" /></span>
					</li>
				</ul>
			</div>
		</div>
		<div class="button-group">
			<input type="button" class="btn btn-default" id="butQuery" name="butQuery" value="<%=MessageResourcesUtils.getMessage(request, "common.button.query") %>" />
			<input type="button" class="btn btn-default" id="butAdd" name="butAdd" value="<%=MessageResourcesUtils.getMessage(request, "common.button.add") %>" />
		</div>
		<table width="100%">
			<tbody>
				<tr>
					<td>
						<table id="datagrid"></table>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</form>
<script type="text/javascript">
	$(document).ready(function() {
		$("#name").issNewMagnifier({
			title: '<%=MessageResourcesUtils.getMessage(request, "systemmanage.databasebinding.storemagnifiertitle") %>',
			url: '${systemctx}/publicMagnifier/publicMagnifier.json',
			sortName : 'modifytime',
			sortOrder : 'desc',
			linkName: 'number',
			callSqlKey: 'queryStoreMagnifierSql',
			changeIgnore: ['name'],
			columns: [[
					{title:'<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.number") %>', field:'number', width:180, sortable:true, align: 'left'},
					{title:'<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.name") %>', field:'name', sortable:true, align: 'left', formel:'name'}
			]],
			onBeforeOpen:function(p){
		      var queryParams = {
		    		  querystore: '%' + $("#name").val() + '%',
		    		  statusid: <%=SysConstant.RecordStatus.VALID %>,
		    		  state : <%=SysConstant.CommonApproveStatus.OK %>
		      };
		      return queryParams;
		    }
		});
		
		//加载分页控件 datagrid
		$('#datagrid').issdatagrid({
			formid : 'form1',
			title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.list") %>',
			width : 'auto',
			nowrap : true,
			autoRowHeight : false,
			singleSelect : true,
			striped : true,
			//collapsible:true,
			url : '${systemctx}/dailyoperation/storechargemanage/querystorechargemanageListInfoDataGrid.json',
			sortName : 'modifytime',
			sortOrder : 'desc',
			remoteSort : true,
			idField : 'id',
			pagination : true,
			rownumbers : true,
			showFooter : true,
			queryParams:$('#form1').serializeObject(),
			columns : [ [ 
				{
					field : 'id',
					title : '<%=MessageResourcesUtils.getMessage(request, "common.button.operation") %>',
					width : 90,
					align : 'center',
					formatter : operate
				},
			    {
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.storecode") %>',
					field : 'number',
					width : 220,
					sortable : true,
					align : 'left',
					formatter: function(value,row,index){
							return "<a href=\"javascript:void(0);\" onclick=\"view('"+row.id+"')\">"+value+"</a>";
					}
				},{
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.storechargemanage.storename") %>',
					field : 'name',
					width : 180,
					sortable : true,
					align : 'left'
				},{
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.services.servicesList.servicenum") %>',
					field : 'servicenum',
					width : 120,
					sortable : true,
					align : 'left'
				},{
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.services.servicesList.servicename") %>',
					field : 'servicename',
					width : 120,
					sortable : true,
					align : 'left'
				},{
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.isproposed") %>',
					field : 'isproposed',
					width : 100,
					sortable : true,
					align : 'center'
				},{
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.proposedprice") %>',
					field : 'proposedprice',
					width : 100,
					sortable : true,
					align : 'right',
					formatter: function(value,row,index){
						if(value == "0.00")
							return "";
						else
							return value;
					}
				},{
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.ismonth") %>',
					field : 'ismonth',
					width : 100,
					sortable : true,
					align : 'center'
				},{
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.chargemanage.monthprice") %>',
					field : 'monthprice',
					width : 100,
					sortable : true,
					align : 'right',
					formatter: function(value,row,index){
						if(value == "0.00")
							return "";
						else
							return value;
					}
				},{
					title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.services.storeservicesguajieList.checkstatus") %>',
					field : 'checkstatus',
					width : 100,
					sortable : true,
					align : 'center'
				},{
					field : 'serviceid',
					hidden: true
				},{
					field : 'storeid',
					hidden: true
				} ] ],
				onLoadSuccess : function(data) {
					//显示AJAX请求后的提示信息
				}
			});

			$('#butQuery').click(function() {
				$('#datagrid').datagrid('load',$('#form1').serializeObject());
			});
			
			$('#butAdd').click(function(){
				
				$(this).isswindow({
					noheader : true,
					url : '${systemctx}/dailyoperation/storechargemanage/toAddStoreChargeManage.web'
				});
			})
			
			function operate(val, row) {
				var checkstatus = row.checkstatus;
				if(checkstatus == '<%=SysConstant.CheckStatus.getName(SysConstant.CheckStatus.CHECKED) %>'){
					return '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="StoreChargeManageupdate('
								+ val + ')"><%=MessageResourcesUtils.getMessage(request, "common.button.update") %></a> ' +
					       '<a disabled="disabled" class="easyui-linkbutton disabled" style="color:grey"><%=MessageResourcesUtils.getMessage(request, "common.button.delete") %></a>';
				}else{
					return '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="StoreChargeManageupdate('
						+ val + ')"><%=MessageResourcesUtils.getMessage(request, "common.button.update") %></a> ' +
							'<a href="javascript:void(0);" class="easyui-linkbutton" onclick="StoreChargeManagedelete('
						+ val + ')"><%=MessageResourcesUtils.getMessage(request, "common.button.delete") %></a> ';
				}
				
			}
	});
	
	function StoreChargeManagedelete(val){
		var id = val;
		if (confirm("<%=MessageResourcesUtils.getMessage(request, "alertinfo.common.jsp.alert2") %>")) {
			//正在执行...
			showSending();
			$.ajax({
				type : 'GET',
				url : '${systemctx}/dailyoperation/storechargemanage/deletestorechargemanage.json?id=' + id,
				dataType : 'json',
				success : function(data) {
					//关闭执行...
					closeSending();
					//显示AJAX请求后的提示信息
					$.fn.ajaxmessage(data);
					$('#datagrid').datagrid('reload',
					$('#form1').serializeObject());
					$('#datagrid').datagrid('clearSelections');
				}
			});
		}
	}
	
	function StoreChargeManageupdate(val){
		var id = val
		$(this).isswindow({
			noheader : true,
			url : '${systemctx}/dailyoperation/storechargemanage/toStoreChargeManageUpdate.web?id='+id
		});
	}
	
	function view(val){
		var id = val
		$(this).isswindow({
			noheader : true,
			url : '${systemctx}/dailyoperation/storechargemanage/toStoreChargeManageView.web?id='+id
		});
	}

</script>
<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>